unit fContractSel;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, dxExEdtr, dxCntner, dxTL, dxDBCtrl, dxDBGrid, DB, DBClient, uCommonclass,
  dxDBTLCl, dxGrClms, uCommonFunc, uCommonVar;

type
  TfrmContractSel = class(TForm)
    dxdbgrd1: TdxDBGrid;
    dxdbgrdclmnCustomerCode: TdxDBGridColumn;
    dxdbgrdclmnCustomerSimpleCode: TdxDBGridColumn;
    dxdbgrdclmnCustomerSimpleName: TdxDBGridColumn;
    dxdbgrdclmnContractNum: TdxDBGridColumn;
    dxdbgrdclmnStoreFullName: TdxDBGridColumn;
    ds1: TDataSource;
    cds1: TClientDataSet;
    dxdbgrdclmnCustomerName: TdxDBGridColumn;
    dxdbgrdmgclmnTerminated: TdxDBGridImageColumn;
    dxdbgrdclmnPosition: TdxDBGridColumn;
    dxdbgrdclmnTerminateDate: TdxDBGridColumn;
    procedure FormShow(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure dxdbgrd1DblClick(Sender: TObject);
    procedure dxdbgrd1CustomDrawCell(Sender: TObject; ACanvas: TCanvas;
      ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxTreeListColumn;
      ASelected, AFocused, ANewItemRow: Boolean; var AText: String;
      var AColor: TColor; AFont: TFont; var AAlignment: TAlignment;
      var ADone: Boolean);
  private
    { Private declarations }
  public
    { Public declarations }
    gDBSuperMan: TDBSuperMan;    
  end;

var
  frmContractSel: TfrmContractSel;

implementation

{$R *.dfm}

procedure TfrmContractSel.FormShow(Sender: TObject);
begin
  gDBSuperMan.Table := 'vw_ContractBasic';
  gDBSuperMan.WhereCondition := 'where verified = ''1'' and deleted = ''0''';
  gDBSuperMan.OrderCondition := 'order by cast(customer_simple_code as int)';
  gDBSuperMan.DBGrid := dxdbgrd1;
  gDBSuperMan.FieldsPanel := nil;
  gDBSuperMan.PrepareData;
  gDBSuperMan.ExecuteOperate;

  GC_SetImageColumnList(dxdbgrdmgclmnTerminated, flg_IsVerified);
end;

procedure TfrmContractSel.FormCreate(Sender: TObject);
begin
  gDBSuperMan := TDBInquireSuperMan.Create;
end;

procedure TfrmContractSel.dxdbgrd1DblClick(Sender: TObject);
begin
  ModalResult := mrOk;
end;

procedure TfrmContractSel.dxdbgrd1CustomDrawCell(Sender: TObject;
  ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode;
  AColumn: TdxTreeListColumn; ASelected, AFocused, ANewItemRow: Boolean;
  var AText: String; var AColor: TColor; AFont: TFont;
  var AAlignment: TAlignment; var ADone: Boolean);
begin
  if ANode.Values[6] = '1' then
    AFont.Color := clRed;
end;

end.
